#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int n, t;
int ep = 0;
vector<int> ff;//其中一方的五代人编号
vector<int> mf;//另一方的五代人编号
set<int> all;//合并俩个人的五代人编号

struct EDGE
{
    int s, e;
    EDGE *next;
} edges[20005];

struct NODE
{
    char sex;
    EDGE *first;
} nodes[100000];

//易错点！！要传入父母的性别！否则如果比较两个父母的话性别是未初始化的直接Never Mind了
//改了之后直接从17分到25分，本来错了134测试点一次过
void addedge(int a, int b, char sex)
{
    edges[ep].s = a;
    edges[ep].e = b;
    edges[ep].next = nodes[a].first;
    nodes[a].first = &edges[ep];
    nodes[b].sex = sex;
    ep++;
}

void addfm(int son, vector<int> &s, int t)
{
    t--;
    if (t == 0)
    {
        return;
    }
    EDGE *e = nodes[son].first;
    while (e != NULL)
    {
        s.push_back(e->e);
        addfm(e->e, s, t);
        e = e->next;
    }
}

bool permit(int a, int b)
{
    addfm(a, ff, 5);//初始化a的五代人编号
    addfm(b, mf, 5);//初始化b的五代人编号
    int cnt1 = ff.size();
    int cnt2 = mf.size();
    ff.insert(ff.end(), mf.begin(), mf.end());//合并到ff中
    all.insert(ff.begin(), ff.end());//拷贝到set容器all中，去重
    int cnt3 = all.size();
    return (cnt3 == (cnt1 + cnt2));
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int id, father, mother;
        char sex;
        cin >> id >> sex >> father >> mother;
        nodes[id].sex = sex;
        if (father != -1)
        {
            addedge(id, father, 'M');
        }
        if (mother != -1)
        {
            addedge(id, mother, 'F');
        }
    }
    cin >> t;
    while (t--)
    {
        int a, b;
        cin >> a >> b;
        if (nodes[a].sex == nodes[b].sex)
        {
            cout << "Never Mind" << endl;
        }
        else
        {
            vector<int>().swap(ff);
            vector<int>().swap(mf);
            set<int>().swap(all);
            if (permit(a, b))
            {
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
    }
    return 0;
}